package com.rao.travel.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Srao
 * @version 1.0
 * @className DateUtils
 * @date 2019/10/28 21:30
 * @package com.rao.travel.utils
 * @description
 */
public class DateUtils {
    /*将日期转换为字符串*/
    public static String date2string(Date date, String pattern){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        return simpleDateFormat.format(date);
    }

    /*把字符串转换成日期*/
    public static Date string2date(String date, String pattern) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        return simpleDateFormat.parse(date);
    }
}
